package com.example.iscore;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class NewActivity extends Activity {

   private EditText  username=null;
   private EditText  password=null;
   private EditText  mail=null;
   private Button inscription;

   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_new);
      username = (EditText)findViewById(R.id.editText1);
      password = (EditText)findViewById(R.id.editText2);
      mail = (EditText)findViewById(R.id.editText3);
      inscription = (Button)findViewById(R.id.button1);
  
   }

   public void inscrire(View view){
      if(username.getText().toString().length() > 0 && 
      password.getText().toString().length() > 0 &&
      mail.getText().toString().contains("@")) {
	      Toast.makeText(getApplicationContext(), "Identifiez-vous...", 
	      Toast.LENGTH_SHORT).show();
	      
	      // on ajoute le new user a la bdd et on redirige pour qu il s authentifie
	      
	      Intent intent = new Intent(NewActivity.this, MainActivity.class);
  		  startActivity(intent);
      }
      else {
	      Toast.makeText(getApplicationContext(), "Mauvais format, veuillez reessayer",
	      Toast.LENGTH_SHORT).show();
      }
   }
   
   @Override
   public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
   }

}